﻿<!DOCTYPE html>
<html>
<head>
    <title>送你一份中秋大礼，能不能带走看你了！</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/mdialog.css">
    <style>
        body
        {
            background: #222657;
            overflow-x: hidden;
            font-family: 微软雅黑;
        }
        .bg
        {
            width: 100%;
            height: auto;
            margin: 0px;
            padding: 0px;
        }
        .bg-img
        {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0px;
            left: 0px;
        }
        .g-lottery-case
        {
            width: 50%;
            height: 500px;
            margin: 0 auto;
            overflow: hidden;
            background: #ccc;
            position: absolute;
            z-index: 20000;
        }
        .g-lottery-box .playbtn
        {
            width: 201px;
            height: 201px;
            position: absolute;
            top: 44%;
            left: 33%;
            background: url(img/lottery/抽奖-OK-01.png) no-repeat;
        }
        .rotate_wrap
        {
            width: 100%;
            max-width: 300px;
            height: 300px;
            margin: 180px auto 20px;
            position: relative;
            text-align: center;
        }
        .bg_img
        {
            width: 100%;
            position: absolute;
            top: 0;
            left: 0;
        }
        .cont_img
        {
            width: 100px;
            position: absolute;
            top: 100px;
            left: 100px;
        }
        .rotate_origin
        {
            transform-origin: 50% 50%;
            -ms-transform-origin: 50% 50%;
            -webkit-transform-origin: 50% 50%;
            -moz-transform-origin: 50% 50%;
            -o-transform-origin: 50% 50%;
        }
        .rotate_origin1
        {
            transform-origin: 50% 85%;
            -ms-transform-origin: 50% 85%;
            -webkit-transform-origin: 50% 85%;
            -moz-transform-origin: 50% 85%;
            -o-transform-origin: 50% 85%;
        }
        .container
        {
            display: block;
            position: absolute;
            margin: 40px auto;
            top: 40px;
            width: 88%;
            float: left;
            right: 0px;
            left: 0px;
        }
        
        .show-p
        {
            position: relative;
            float: left;
            width: 100%;
            border: none;
            border-radius: 5px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
            background: #fff;
            text-align: center;
            font-size: 16px;
        }
        .show-img
        {
            padding-top: 10px;
        }
        .cusbtn
        {
            display: block;
            width: 100%;
            height: 50px;
            padding: 0;
            background: #e26e54;
            line-height: 50px;
            text-align: center;
            text-decoration: none;
            text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
            font-size: 1.2em;
            font-family: "microsoft yahei";
            font-weight: 400;
            color: #fff;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-shadow: 0 0 0 transparent;
        }
        .frow
        {
            float: left;
            display: block;
            width: 100%;
            margin-bottom: 20px;
        }
        .btn-cl
        {
            background: url(img/close.png) no-repeat;
            position: relative;
            z-index: 20002;
            top: 35px;
            right: 8px;
            height: 28px;
            width: 28px;
            float: right;
        }
        .txt-msg
        {
            font-size: 16px;
            padding-bottom: 5px;
        }
        .m-head
        {
            border-radius: 10px 10px 0px 0px;
            height: 40px;
            line-height: 40px;
            background: #e26f54;
            color: #fff;
            font-size: 22px;
        }
        .content
        {
            text-align: left;
            padding: 10px 15px;
            width: 90%;
            font-size: 14px;
        }
        .content div
        {
            width: 100%;
            float: left;
            padding-bottom: 15px;
            line-height: 20px;
        }
        .content h4
        {
            float: left;
            width: 80px;
        }
    </style>
</head>
<body>
    <img class="bg-img" src="img/til-bg2.png" />
    <img class="bg-img" src="img/lottery/抽奖-OK-16.png" />
    <div class="rotate_wrap">
        <img class="bg_img rotate_origin" id="i_bg" src="img/lottery/抽奖-OK-17-1.png">
        <img class="cont_img rotate_origin1" id="i_cont" src="img/lottery/playbtn.png">
        <div style="position: fixed; bottom: 0px; left: 0px; right: 0px; color: #fff; font-size: 12px;
            text-align: center; width: 100%; display: none;">
            本次活动最终解释权归广州卡门实业有限公司所有。
        </div>
        <div style="position: fixed; bottom: 0px; left: 0px; right: 0px; width: 100%; text-align: left;">
            <a id="btnstr" href="#">
                <img src="img/a_des.png" height="20px" width="95px" /></a>
        </div>
    </div>
    <div id="msg1" class="container" style="display: none;">
        <a class="btn-cl" href="javascript:msgclose('msg1');"></a>
        <div class="show-p">
            <div class="show-img">
                <img id="myimg" src="img/img1.png" />
            </div>
            <div>
                恭喜您
            </div>
            <div>
                获得<span style="color: Red;" id="prdname">中秋巨无比大礼包</span>
            </div>
            <div id="des" style="color: Red;">
            </div>
            <div id="des2" style="color: Gray; font-size: 11px;">
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpay" class='cusbtn' href='#'>去领奖</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg2" class="container" style="display: none;">
        <a class="btn-cl" href="javascript:msgclose('msg2');"></a>
        <div class="show-p" style="font-size: 18px;">
            <div class="show-img">
                <img id="Img1" src="img/img4.png" />
            </div>
            <div>
                呜呼！差一点就中奖了！
            </div>
            <div>
                然而，什么都没有
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpayno" class='cusbtn' href='#'>我不信</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg3" class="container" style="display: none;">
        <a class="btn-cl" href="javascript:msgclose('msg3');"></a>
        <div class="show-p" style="font-size: 16px;">
            <div class="show-img">
                <img id="Img2" src="img/img4.png" />
            </div>
            <div class="txt-msg">
                您今天的抽奖机会已用完,
            </div>
            <div class="txt-msg">
                分享你的中秋礼物给好友吧
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpayun" class='cusbtn' href='#'>我不信</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg4" class="container" style="display: none;">
        <a class="btn-cl" href="javascript:msgclose('msg4');"></a>
        <div class="show-p" style="font-size: 18px;">
            <div class="show-img">
                <img id="Img3" src="img/img5.png" />
            </div>
            <div>
                再来一次！
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btn5" class='cusbtn' href='#'>返回首页</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg5" class="container" style="display: none;">
        <a class="btn-cl" style="background: url(img/close2.png) no-repeat;" href="javascript:msgclose('msg5');">
        </a>
        <div class="show-p" style="font-size: 14px; border-radius: 10px 10px">
            <div class="m-head">
                活动规则</div>
            <div class="content">
                <div>
                    <h4>
                        活动时间：</h4>
                    <span>即日起至9月15日</span>
                </div>
                <div>
                    <h4>
                        活动内容：</h4>
                    凭购物小票注册KM会员，即可免费参与KM中秋抽奖活动，赢取中秋大礼。
                </div>
                <div>
                    <h4>
                        参与方式：</h4>
                    <span style="color: Red;">每用户每日3次抽奖机会，听说分享朋友圈中奖几率更大哦！</span>
                </div>
                <div>
                    <h4>
                        奖品设置：</h4>
                    中秋巨无霸大礼包、7天酒店全国通用100元豪华大礼包、中秋月饼礼。
                </div>
                <div>
                    <h4>
                        奖品兑换：</h4>
                    中奖后在活动页面输入物流信息，等待奖品全国包邮派送，收到奖品后记得分享幸运给KM官微哦。
                </div>
                <div>
                    ※ 本活动最终解释权归广州卡门实业有限公司所有。</div>
            </div>
        </div>
    </div>
    <div id="msg6" class="container" style="display: none;">
        <a class="btn-cl" href="javascript:msgclose('msg6');"></a>
        <div class="show-p" style="font-size: 28px;">
            <div class="show-img">
                <img id="Img4" src="img/img4.png" />
            </div>
            <div style="padding:5px 80px;">
                本次活动已结束，敬请期待下次哦！
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <script src="js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery.rotate.min.js"></script>
    <script src="js/Script.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/zepto.min.js"></script>
    <script type="text/javascript" src="js/mdialog.js"></script>
    <script language="javascript" type="text/javascript">
        /* $(function () {
        //分享接口验证
        $.ajax({
        url: url_path + "/AjaxContrls/UnitControler.aspx",
        type: "POST",
        data: { aciton: 'getwxconfig' },
        timeout: 30000,
        dataType: "json",
        success: function (data) {
        if (data.status == 0) {
        wx.config({
        debug: true, //这里是开启测试，如果设置为true，则打开每个步骤，都会有提示，是否成功或者失败
        appId: data.appid,
        timestamp: data.timestamp, //这个一定要与上面的php代码里的一样。
        nonceStr: data.nonceStr, //这个一定要与上面的php代码里的一样。
        signature: data.signature,
        jsApiList: ['onMenuShareTimeline']
        });
        wx.ready(function () {
        wx.onMenuShareTimeline({
        title: "会穿的人儿都在抽中秋大奖", // 分享标题
        link: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6d3a3a25e9576db6&redirect_uri=http%3A%2F%2Fweixin.km-china.cn%2Fkmwx%2Flottery.html&response_type=code&scope=snsapi_base&state=123", // 分享链接
        imgUrl: "http://mmbiz.qpic.cn/mmbiz_jpg/70KUcLjnuYAvck2NBNibicPURFVwE80ia5UrQ8E3DEad4ZKW2JwOR9XhzKvf92vGxEogUE2vlCqYALkFpUomBY0qw/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1", // 分享图标
        success: function () {
        alert("分享成功！");
        },
        cancel: function () {
        // 用户取消分享后执行的回调函数
        alert("取消分享！");
        }
        });
        });
        } else {
        alert("出现问题");
        }
        },
        error: function () {
        alert("数据超时！");
        }
        });
            
        });*/
    </script>
    <script>
        var playnum = 0;
        var openid = null;
        var pid = 0;
        var $btn = $('.cont_img');
        $(function () {
            //openid = $.getUrlParam('openid');
            var code = $.getUrlParam('code');
            if (openid == null)
                getopenid(code);
            //初始次数，由后台传入
            $('.playnum').html(playnum);
            var isture = 0;
            var clickfunc = function () {
                var data = [1, 2, 3, 4, 5];
                var oArr = { '1': [1, 2], '2': [2, 2], '3': [3, 1], '4': [4, 495], '5': [5, 500] };
                //var oArr = { '1': [1, 5], '2': [2, 5], '3': [3, 5], '4': [4, 35], '5': [5, 50] };
                data = prizeRand(oArr);
                /*
                //data为随机出来的结果，根据概率后的结果
                var rd = Math.random();
                if (rd >= 0.6) {//40%
                data = 5;
                }
                else if (rd <0.1 || (rd >0.4 && rd <0.6)) {//20%
                data = 4;
                }
                else
                data = data[Math.floor(rd * data.length)];*/

                if (data == 4 || data == 5) {
                    goto(data);
                } else
                    checkstock(data);
            }
            $("#btnpay").live("click", function () {
                window.location.href = 'address.html?openid=' + openid + '&pid=' + pid;
            });
            $("#btnpayno").live("click", function () {
                //window.location.href = 'http://mp.weixin.qq.com/s?__biz=MzIwMTA1NjEzOQ==&mid=2651136492&idx=1&sn=b4841f8e0c4a583586bf57d4d97d2ca6&scene=0#wechat_redirect';
                window.location.href = 'http://mp.weixin.qq.com/s?__biz=MzIwMTA1NjEzOQ==&mid=2651136619&idx=2&sn=c99771b18c961e1d8254d45c94845afe&chksm=8d02488fba75c19953d5b5742e03b20b94633d2c2352949a90016a009f5cd237d9d6d4814d07&scene=0#wechat_redirect';
            });
            $("#btnpayun").live("click", function () {
                window.location.href = 'http://mp.weixin.qq.com/s?__biz=MzIwMTA1NjEzOQ==&mid=2651136619&idx=2&sn=c99771b18c961e1d8254d45c94845afe&chksm=8d02488fba75c19953d5b5742e03b20b94633d2c2352949a90016a009f5cd237d9d6d4814d07&scene=0#wechat_redirect';
            });
            $("#btn5").live("click", function () {
                $("#msg4").hide();
            });
            $("#btnstr").live("click", function () {
                $("#msg5").show();
            });
            function goto(data) {
                switch (data) {
                    case 1:
                        rotateFunc(1, -40, '中秋巨无霸大礼包');
                        break;
                    case 2:
                        rotateFunc(2, 30, '北欧风味月饼礼盒');
                        break;
                    case 3:
                        rotateFunc(3, 110, '7天酒店全国通用100元大礼包');
                        break;
                    case 4:
                        rotateFunc(4, 180, '然而，什么都没有');
                        break;
                    case 5:
                        rotateFunc(5, 250, '再来一次');
                        break;
                }
            }
            function getopenid(code) {
                alert(code);
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'getwxopenid', code: code },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status != -1) {
                            openid = data.openid;
                            $btn.click(function () {
                                if (isture) return; // 如果在执行就退出
                                isture = true; // 标志为 在执行
                                btnplay();
                            });
                        } else {
                            window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6d3a3a25e9576db6&redirect_uri=http%3A%2F%2Fweixin.km-china.cn%2Fkmwx%2Flottery.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
                        }
                    },
                    error: function () {
                        alert("");
                    }
                });
            }
            function btnplay() {
                $("#msg6").show();
                return;
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'updwxopenid', openid: openid, pid: pid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            clickfunc();
                        } else if (data.status == 1) {
                            isture = false;
                            $("#msg3").show();
                        }
                    },
                    error: function () {
                        alert("数据超时！");
                    }
                });
            }
            function againplay() {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'updwxpaynum', openid: openid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            playnum = 1;
                        }
                    },
                    error: function () {
                    }
                });
            }
            function checkstock(pid) {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'checkstock', pid: pid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            goto(pid);
                        } else if (data.status == 1) {
                            goto(4);
                        } else {
                            alert(data.msg);
                        }
                    },
                    error: function () {
                    }
                });
            }
            var rotateFunc = function (awards, angle, text) {
                isture = true;
                $btn.stopRotate();
                $btn.rotate({
                    angle: 0,
                    duration: 4000, //旋转时间
                    animateTo: angle + 1440, //让它根据得出来的结果加上1440度旋转
                    callback: function () {
                        pid = awards;
                        //alert(text);
                        if (awards == 5) {
                            playnum += 1;
                        }
                        if (awards == 1 || awards == 2 || awards == 3) {
                            $("#msg1").show();
                            $("#prdname").text(text);
                            $("#myimg").attr('src', 'img/img' + awards + '.png');
                            if (awards == 3) {
                                $("#des").text("有效期：3个月");
                                $("#des2").text("7天连锁，7天优品，派酒店，全国通用");
                            }
                        } else {
                            if (awards == 4) {
                                $("#msg2").show();
                            } else {
                                //new TipBox({ type: 'tip', str: '恭喜您，再来一次吧！', clickDomCancel: true, setTime: 10000500, hasBtn: true });
                                //againplay();
                                $("#msg4").show();
                            }
                        }
                        //插入抽奖日志
                        $.ajax({
                            url: url_path + "/AjaxContrls/UnitControler.aspx",
                            type: "POST",
                            data: { aciton: 'insetlogs', openid: openid, pid: awards },
                            dataType: "json",
                            success: function (data) {
                                if (data.status == 0) {
                                    isture = false; // 标志为 执行完毕
                                }
                            }
                        });
                        //                        switch (awards) {
                        //                            case 1:
                        //                                window.location.href = 'result1.html?openid=' + openid;
                        //                                break;
                        //                            case 2:
                        //                                window.location.href = 'result2.html?openid=' + openid;
                        //                                break;
                        //                            case 3:
                        //                                window.location.href = 'result3.html?openid=' + openid;
                        //                                break;
                        //                            case 4:
                        //                                window.location.href = 'result4.html?openid=' + openid;
                        //                                break;
                        //                            case 5:
                        //                                new TipBox({ type: 'tip', str: '恭喜您，再来一次吧！', clickDomCancel: true, setTime: 10000500, hasBtn: true });
                        //                                againplay();
                        //                                break;
                        //                        }
                    }
                });
            };
        });
        function msgclose(ojb) {
            $('#' + ojb).hide();
        }
    </script>
</body>
</html>
